import request from '@/utils/request';
import {
  Menu,
  CreateMenuRequest,
  UpdateMenuRequest,
  MenuListParams,
  DeleteMenuParams,
  MenuDetailParams,
} from '@/types/menu';
import { PaginationResponse } from '@/types/api-common';

export const getMenuList = (params?: MenuListParams) => {
  return request.post<Menu[]>('/api/admin/menus/list', params || {});
};

export const getMenuPage = (params: MenuListParams) => {
  return request.post<PaginationResponse<Menu>>('/api/admin/menus/page', params);
};

export const createMenu = (data: CreateMenuRequest) => {
  return request.post<Menu>('/api/admin/menus/create', data);
};

export const updateMenu = (data: UpdateMenuRequest) => {
  return request.post<Menu>('/api/admin/menus/update', data);
};

export const deleteMenu = (data: DeleteMenuParams) => {
  return request.post('/api/admin/menus/delete', data);
};

export const getMenuDetail = (params: MenuDetailParams) =>
  request.post<Menu>('/api/admin/menus/detail', params);